{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>添加消息</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">
            <input type="hidden" name="id" value="{$res.n_id}">
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">消息名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="n_name" value="{$res.n_name}" lay-verify="required" placeholder="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">消息内容：</label>
                <div class="layui-input-block">
                    <textarea type="text" style="height:153px;width:398px;" name="n_content" lay-verify="required" placeholder="" class="layui-input"><?php echo(html_entity_decode($res['n_content']?$res['n_content']:''))?></textarea>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">是否设置发送时间：</label>
                <div class="layui-input-block">
                    <select name="n_publish_time" class="publish" lay-filter="aaaaa">
                        <option value="1" {if $res['n_status']==0}selected{/if}>是</option>
                        <option value="2" {if $res['n_status']==1}selected{/if}>否</option>
                    </select>
                </div>
            </div>
            {if $res['n_status']==0}
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8 bbbbb">
                <label class="layui-form-label">发送时间：</label>
                <div class="layui-input-block">
                    <input type="text"  name="start" value="{$res['n_publish_time']?$res['n_publish_time']:''}" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="开始日期" />
                </div>
            </div>
            {else /}
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8 bbbbb" style="display:none">
                <label class="layui-form-label">发送时间：</label>
                <div class="layui-input-block">
                    <input type="text" value="{$res['n_publish_time']?$res['n_publish_time']:''}" name="start" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="开始日期" />
                </div>
            </div>
            {/if}

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                    <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer" /}
<script>
    layui.use(['form'], function() {
        var form = layui.form;
        form.on('select(aaaaa)', function(data){
            if(data.value==1){
                $(".bbbbb").show();
            }else{
                $(".bbbbb").hide();
            }
        });
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('update')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('notice/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
                    }
                }
            })
        });
    });
</script>
<script>
    wk.uploadFile({size:20,url:"{:url('Upload/uploadLocality')}"});
    wk.uploadFile({size:20,num:1,url:"{:url('Upload/uploadLocality')}"});
</script>
</body>
</html>